<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>组织生活详情</title>
	<meta name="decorator" content="default"/>		
		<script src="<%=request.getContextPath()%>/static/layer/layer.js"></script>
	
	
	
	<script type="text/javascript">
		$(document).ready(function() {
			
			function checkDate( sDate, Edate){
				var starttime = $('#starttime').val();  
				var endtime = $('#endtime').val();  
				var start = new Date(starttime.replace("-", "/").replace("-", "/"));  
				var end = new Date(endtime.replace("-", "/").replace("-", "/"));  				
				if(end<start){    
				    return false;    
				} else{
					return true;    
				}
			}			
		
			$("#inputForm").validate({								
				submitHandler: function(form){
					var starttime = $('#starttime').val();  
					var endtime = $('#endtime').val();  
					var obj=document.getElementsByName("typeids"); //选择所有name="'test'"的对象，返回数组 					
					var s=''; 
					for(var i=0; i<obj.length; i++){ 
					if(obj[i].checked) s+=obj[i].value+','; //如果选中，将value添加到变量s中 
					} 
					if(s==""){
						alert("请选择组织生活申报的类型！")
					}else if(starttime!=null && endtime!=null && starttime!="" && endtime!="" && !checkDate(starttime,endtime)){						
							alert("结束时间不能大于开始时间！")
							return false;										
					}else if(CKEDITOR.instances.contentzy.getData()==null || CKEDITOR.instances.contentzy.getData()==""){
						alert("请填写内容摘要！");
					}else{
						loading('正在提交，请稍等...');
						form.submit();
					}		
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});			
	    });
		//弹出选择应到党员页面
		function selectPerson() {
			var html ="";
			$.ajax({
				url : "${ctx}/life/organizeLifeJh/getPersonByOrgid",
				type : "get",
				dataType : "json",
				async : false,//同步  
				success : function(text) {
					html +=  "<div style='text-align:center'>"
						+"<input id='xgBtn1' onclick='qx()' class='btn libts'  type='button' value='全选'/>&nbsp;"
						+"<input id='xgBtn1' onclick='qbx()' class='btn libts'  type='button' value='取消全选'/>&nbsp;"
					+"<input id='xgBtn1' onclick='xg()' class='btn libts' style='background: red; color: #FFF;' type='button' value='确认'/></div>"
					+"<div style='padding: 20px 40px;'><table>"
					for (var i = 0; i < text.length; i++) {
						html+="<tr id='"+ (i + 1)+ "'>"
										+ "<td><input type='checkbox' id='ids' name='ids' value="+text[i].userName+"></td>"
										+ "<td><span style='color:black'>"+text[i].userName+"</span></td>"
										+ "</tr>";
										}
					html+="</table></div>"
					
				}
			});

			layer.open({
						type : 1,
						skin : 'layui-layer-rim', // 加上边框
						area : [ '300px', '400px' ],
						title : '请选择参会人员',
						content : html
					});
		}
		//弹出选择请假党员页面
		function selectPersonQj() {
			var html ="";
			$.ajax({
				url : "${ctx}/life/organizeLifeJh/getPersonByOrgid",
				type : "get",
				dataType : "json",
				async : false,//同步  
				success : function(text) {
					html += "<div style='text-align:center'>"
					+"<input id='xgBtn1' onclick='qxQj()' class='btn libts'  type='button' value='全选'/>&nbsp;"
					+"<input id='xgBtn1' onclick='qbxQj()' class='btn libts'  type='button' value='取消全选'/>&nbsp;"
					+"<input id='xgBtn1' onclick='xgQj()' class='btn libts' style='background: red; color: #FFF;' type='button' value='确认'/></div>" 
						+"<div style='padding: 20px 80px;'><table>"
					for (var i = 0; i < text.length; i++) {
						html+="<tr id='"+ (i + 1)+ "'>"
										+ "<td><input type='checkbox' id='idsQj' name='idsQj' value="+text[i].userName+"></td>"
										+ "<td><span style='color:black'>"+text[i].userName+"</span></td>"
										+ "</tr>";
										}
					html+="</table></div>"
					
				}
			});

			layer.open({
						type : 1,
						skin : 'layui-layer-rim', // 加上边框
						area : [ '300px', '400px' ],
						title : '请选择请假人员',
						content : html
					});
		}
		function xg() {
			var ids = [];
			$("input[name='ids']:checked").each(function() {
				ids.push($(this).val());
			});
			if(ids.length==0){
				alert("请选择参会人员!");
			}else{
				layer.closeAll();
				$("#bmperson").val(ids);
				$("#ydnum").val(ids.length);
			}
		}
		function xgQj() {
			var idsQj = [];
			$("input[name='idsQj']:checked").each(function() {
				idsQj.push($(this).val());
			});
			if(idsQj.length==0){
				alert("请选择请假人员!");
			}else{
				layer.closeAll();
				$("#qjperson").val(idsQj);
				$("#qxnum").val(idsQj.length);
			}
		}
		function qx() {
			$("input[name='ids']").prop("checked", true);
		}
        function qbx() {
        	$("input[name='ids']").prop("checked", false);
		}
		
		function qxQj() {
			$("input[name='idsQj']").prop("checked", true);
		}
        function qbxQj() {
        	$("input[name='idsQj']").prop("checked", false);
		}
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a>组织生活申报修改</a></li>
	</ul>
<form:form id="inputForm" modelAttribute="organizeLife" action="${ctx}/life/organizeLifeJh/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
        <div class="control-group">
			<label class="control-label">活动名称：</label>
			<div class="controls">
				<form:input path="lifename" htmlEscape="false" style="width:500px"  class="input-xlarge required"/>
				<span style='color: red;font-size:50%;' >★</span>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">类型：</label>
			<div class="controls">

			<!-- 
			<form:checkboxes path="typeids" items="${listStr}" itemLabel="typename" itemValue="id" htmlEscape="false" class="required"/>
			-->		
			 		
			<c:forEach items="${listStr}" var="order">		
					<c:choose>
				    <c:when test="${order.check=='check'}">
                    <input id="typeids" name="typeids" type="checkbox" value="${order.id }" checked="checked" >${order.typename }	
                    </c:when>
					<c:otherwise>
					<input id="typeids" name="typeids" type="checkbox" value="${order.id }" >${order.typename }
					</c:otherwise>
					</c:choose>					
			</c:forEach>
						<span style='color: red;font-size:50%;' >★</span>
			</div>
		</div>
		
        <div class="control-group">
			<label class="control-label">主持人：</label>
			<div class="controls" style="float:left;margin-left: 20px;">
				<form:input path="compere" htmlEscape="false" style="width:200px"  class="input-xlarge required"/>
				<span style='color: red;font-size:50%;' >★</span>
			</div>
			<label class="control-label" >记录人：</label>
			<div class="" style="float:left;margin-left: 20px;">
				<form:input path="column23" htmlEscape="false" style="width:200px"  class="input-xlarge "/>
			</div>
		</div>
		 <div class="control-group">
			<label class="control-label">活动地点：</label>
			<div class="controls">
				<form:input path="adress" htmlEscape="false" style="width:500px"  class="input-xlarge required"/>
				<span style='color: red;font-size:50%;' >★</span>			
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">应到人数：</label>
			<div class="controls" style="float:left;margin-left: 20px;">
				<form:input path="ydnum" htmlEscape="false" readonly="true" style="width:50px"  class="input-xlarge "/>
			</div>
			<label class="control-label" >实到人数：</label>
			<div class="" style="float:left;margin-left: 0px;">
				<form:input path="sdnum" htmlEscape="false" readonly="true" style="width:50px"  class="input-xlarge "/>
			</div>
			<label class="control-label" >缺席人数：</label>
			<div class="" style="float:left;margin-left: 0px;">
				<form:input path="qxnum" htmlEscape="false" readonly="true" style="width:50px"  class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">计划时间：</label>
			<div class="controls" style="float:left;margin-left: 20px;">
			
			<input name="jhtime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${organizeLife.jhtime}" pattern="yyyy-MM-dd HH:mm"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
			<span style='color: red;font-size:50%;' >★</span>
			</div>
			<label class="control-label" >开始时间：</label>
			<div class="" style="float:left;margin-left: 0px;">
            <input id="starttime" name="starttime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${organizeLife.starttime}" pattern="yyyy-MM-dd HH:mm"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>			</div>
			<label class="control-label" >结束时间：</label>
			<div class="" style="float:left;margin-left: 0px;">
            <input id="endtime" name="endtime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${organizeLife.endtime}" pattern="yyyy-MM-dd HH:mm"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">内容摘要：<span style='color: red;font-size:50%;' >★</span></label>
			<div class="controls">
				<form:textarea id="contentzy" htmlEscape="true" path="contentzy" rows="4" maxlength="200" class="input-xlarge required"/>
				<sys:ckeditor replace="contentzy" uploadPath="/life/organizeLife" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">主要内容：</label>
			<div class="controls">
				<form:textarea id="zycontent" htmlEscape="true" path="zycontent" rows="4" maxlength="200" class="input-xxlarge"/>
				<sys:ckeditor replace="zycontent" uploadPath="/life/organizeLife" />
			</div>
		</div>
	
		 <div class="control-group">
			<label class="control-label">应到党员：</label>
			<div class="controls">            
                <form:textarea path="bmperson" htmlEscape="false" style="width:500px"  class="input-xlarge required" onclick="selectPerson()"/>
                <span style='color: red;font-size:50%;' >★</span>
            </div>			
		</div>
		 <div class="control-group">
			<label class="control-label">请假党员：</label>
			<div class="controls">
				<form:textarea path="qjperson" htmlEscape="false" style="width:500px"  class="input-xlarge" onclick="selectPersonQj()"/>				
			</div>
		</div>
		 <div class="control-group">
			<label class="control-label">实到党员：</label>
			<div class="controls">
				<form:input path="sdperson" htmlEscape="false" style="width:800px"  class="input-xlarge "/>				
			</div>
		</div>
			<div class="control-group">
			<label class="control-label">资料照片：</label>
			<div class="controls">				
				<form:hidden id="yyzl" path="yyzl" htmlEscape="false" maxlength="255" class="input-xlarge"/>				
				<sys:ckfinder input="yyzl" type="images" uploadPath="/life/organizeLife" selectMultiple="true" maxWidth="100" maxHeight="100"/>												
			</div>			
			
		</div>
		<div class="control-group">
			<label class="control-label">附件：</label>
			<div class="controls">				
				<form:hidden id="fujian" path="fujian" htmlEscape="false" maxlength="255" class="input-xlarge"/>
				<sys:ckfinder input="fujian" type="files" uploadPath="/life/organizeLife" selectMultiple="true"/>				
				
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="life:organizeLifeJh:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
		
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>